from django.http.response import HttpResponse
from django.utils.timezone import now, localtime
from faker import Faker
from .models import Article

fake = Faker(locale='zh_CN')


def index(request):
    # article = Article()
    # article.save()

    # now_time = now()
    # local_now_time = localtime(now_time)
    # print(now_time, local_now_time)

    # 添加数据
    # article = Article(title=fake.sentence(), removed=False)
    # article.save()

    # 查询数据
    article = Article.objects.get(pk=5)

    # 更新数据
    # article.title = fake.sentence()
    # article.save()
    print(article.create_time)
    print(localtime(article.create_time))
    return HttpResponse('ORM常用Field详解')
